extends Node


var total_score = 0 # 总分
var bgm_value = 80 # 背景音量
var is_bgm_playing = true
var is_game_playing = true



var current_level = 1 # 当前关卡
var time_scale = 1.0 setget set_time_scale # 时间缩放

# 关卡
var levels_base_path = "res://levels/"
var levels = [
	"1.tscn",
	"2.tscn",
	"3.tscn"
]


# 暂停BGM
func bgm_pause(): 
	Bgm.stream_paused = true
	is_bgm_playing = false

# 继续BGM
func bgm_resume():
	Bgm.stream_paused =  false
	is_bgm_playing = true

# 暂停游戏
func game_pause() -> void:
	get_tree().paused = true
	is_game_playing = false

# 继续游戏
func game_resume() -> void:
	get_tree().paused = false
	is_game_playing = true

# 设置游戏速度
func set_time_scale(speed:float) -> void:
	time_scale = speed
	Engine.time_scale = speed

# 到下一关
func to_next_level():
	if current_level < levels.size():
		change_scene(levels_base_path + levels[current_level])
		current_level += 1
	pass
	
## 到指定的关卡
#func to_level(num:int):
#
#	pass

# 切换场景
func change_scene(fPath:String) -> void:
	get_tree().change_scene(fPath)
	pass
